#include <iostream>
#include <cgicc/Cgicc.h>
#include <jsoncpp/json/json.h>
#include "database_handler/media_control.hh"
using namespace std;
using namespace cgicc;
using namespace leyi_media::media_control;
int main()
{
    cout << "Content-type: plain/text"
         << "\r\n\r\n";
    try
    {
        Cgicc cc;
        Json::Value root;
        auto &element_lists = cc.getElements();
        for (auto &e : element_lists)
        {
            root[e.getName()] = e.getValue();
        }
        if (media_controler_t::get_instance().insert_comment(root) == false)
        {
            cout << "comment upload failed, contact with leyi and he can fix it\n";
            return EXIT_FAILURE;
        }
    }
    catch (const std::exception &e)
    {
        cerr << e.what();
        return EXIT_FAILURE;
    }
    cout << "your comment has reached\n";
    return EXIT_SUCCESS;
}